﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
//using LTP.Accounts.Bus;
namespace HospitalManagement.Web.PrimaryTumor
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int SysNo=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(SysNo);
				}
			}
		}
			
	private void ShowInfo(int SysNo)
	{
		HospitalManagement.BLL.PrimaryTumor bll=new HospitalManagement.BLL.PrimaryTumor();
		HospitalManagement.Model.PrimaryTumor model=bll.GetModel(SysNo);
		this.lblSysNo.Text=model.SysNo.ToString();
		this.txtPatientSysNo.Text=model.PatientSysNo.ToString();
		this.txtHospitalName.Text=model.HospitalName;
		this.txtSurgicalApproach.Text=model.SurgicalApproach;
		this.txtResectionSurgery.Text=model.ResectionSurgery;
		this.txtTumor.Text=model.Tumor;
		this.txtTumorTypes.Text=model.TumorTypes;
		this.txtSickNumber.Text=model.SickNumber;
		this.txtSickText.Text=model.SickText;
		this.txtNecrosisRate.Text=model.NecrosisRate;
		this.txtNecrosisRateVal.Text=model.NecrosisRateVal;
		this.txtSurgeon.Text=model.Surgeon;
        //this.txtDisabled.Text=model.Disabled.ToString();
        //this.txtIndate.Text=model.Indate.ToString();
        //this.txtInUser.Text=model.InUser;
        //this.txtEditDate.Text=model.EditDate.ToString();
        //this.txtEditUser.Text=model.EditUser;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtPatientSysNo.Text))
			{
				strErr+="PatientSysNo格式错误！\\n";	
			}
			if(this.txtHospitalName.Text.Trim().Length==0)
			{
				strErr+="HospitalName不能为空！\\n";	
			}
			if(this.txtSurgicalApproach.Text.Trim().Length==0)
			{
				strErr+="SurgicalApproach不能为空！\\n";	
			}
			if(this.txtResectionSurgery.Text.Trim().Length==0)
			{
				strErr+="ResectionSurgery不能为空！\\n";	
			}
			if(this.txtTumor.Text.Trim().Length==0)
			{
				strErr+="Tumor不能为空！\\n";	
			}
			if(this.txtTumorTypes.Text.Trim().Length==0)
			{
				strErr+="TumorTypes不能为空！\\n";	
			}
			if(this.txtSickNumber.Text.Trim().Length==0)
			{
				strErr+="SickNumber不能为空！\\n";	
			}
			if(this.txtSickText.Text.Trim().Length==0)
			{
				strErr+="SickText不能为空！\\n";	
			}
			if(this.txtNecrosisRate.Text.Trim().Length==0)
			{
				strErr+="NecrosisRate不能为空！\\n";	
			}
			if(this.txtNecrosisRateVal.Text.Trim().Length==0)
			{
				strErr+="NecrosisRateVal不能为空！\\n";	
			}
			if(this.txtSurgeon.Text.Trim().Length==0)
			{
				strErr+="Surgeon不能为空！\\n";	
			}
            //if(!PageValidate.IsNumber(txtDisabled.Text))
            //{
            //    strErr+="Disabled格式错误！\\n";	
            //}
            //if(!PageValidate.IsDateTime(txtIndate.Text))
            //{
            //    strErr+="Indate格式错误！\\n";	
            //}
            //if(this.txtInUser.Text.Trim().Length==0)
            //{
            //    strErr+="InUser不能为空！\\n";	
            //}
            //if(!PageValidate.IsDateTime(txtEditDate.Text))
            //{
            //    strErr+="EditDate格式错误！\\n";	
            //}
            //if(this.txtEditUser.Text.Trim().Length==0)
            //{
            //    strErr+="EditUser不能为空！\\n";	
            //}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int SysNo=int.Parse(this.lblSysNo.Text);
			int PatientSysNo=int.Parse(this.txtPatientSysNo.Text);
			string HospitalName=this.txtHospitalName.Text;
			string SurgicalApproach=this.txtSurgicalApproach.Text;
			string ResectionSurgery=this.txtResectionSurgery.Text;
			string Tumor=this.txtTumor.Text;
			string TumorTypes=this.txtTumorTypes.Text;
			string SickNumber=this.txtSickNumber.Text;
			string SickText=this.txtSickText.Text;
			string NecrosisRate=this.txtNecrosisRate.Text;
			string NecrosisRateVal=this.txtNecrosisRateVal.Text;
			string Surgeon=this.txtSurgeon.Text;
            //int Disabled=int.Parse(this.txtDisabled.Text);
            //DateTime Indate=DateTime.Parse(this.txtIndate.Text);
            //string InUser=this.txtInUser.Text;
            //DateTime EditDate=DateTime.Parse(this.txtEditDate.Text);
            //string EditUser=this.txtEditUser.Text;


			HospitalManagement.Model.PrimaryTumor model=new HospitalManagement.Model.PrimaryTumor();
			model.SysNo=SysNo;
			model.PatientSysNo=PatientSysNo;
			model.HospitalName=HospitalName;
			model.SurgicalApproach=SurgicalApproach;
			model.ResectionSurgery=ResectionSurgery;
			model.Tumor=Tumor;
			model.TumorTypes=TumorTypes;
			model.SickNumber=SickNumber;
			model.SickText=SickText;
			model.NecrosisRate=NecrosisRate;
			model.NecrosisRateVal=NecrosisRateVal;
			model.Surgeon=Surgeon;
            //model.Disabled=Disabled;
            //model.Indate=Indate;
            //model.InUser=InUser;
            //model.EditDate=EditDate;
            //model.EditUser=EditUser;

			HospitalManagement.BLL.PrimaryTumor bll=new HospitalManagement.BLL.PrimaryTumor();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
